﻿using System;
using System.Linq;
using System.Web.Security;
using easyccms.BusinessLayer.Repositories;
using easyccms.WebUI.Infrastructure;

namespace easyccms.WebUI.Code
{
    /// <summary>
    /// My role provider.
    /// </summary>
    public class MyRoleProvider: RoleProvider
    {
        /// <summary>
        /// Gets the user repository.
        /// </summary>
        private ISiteUserRepository UserRepository{get { return DependencyInjector.Resolve<ISiteUserRepository>(); }}

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override string ApplicationName
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }

        public override string[] GetAllRoles()
        {
            throw new NotImplementedException();
        }

        public override string[] GetRolesForUser(string username)
        {
            return UserRepository.All.Where(x => x.Email == username).Select(x => x.UserGroup.GroupName).ToArray();
        }

        public override string[] GetUsersInRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool IsUserInRole(string username, string roleName)
        {
            throw new NotImplementedException();
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new NotImplementedException();
        }
    }
}